551A - GukiZ and Contest - CodeForces Solution


brute force implementation sortings *800

Please click on ads to support us..

Python Code:

n=int(input())
lst=list(map(int,input().split()))
for i in range(n):
    s=1
    for j in range(n):
        if lst[i]<lst[j]: s+=1
    print(s,end=' ')
					 		 			 	  					        	

C++ Code:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define pb push_back
#define pob pop_back
bool isprime(ll n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;
 
    return true;
}
void solve()
{ 
 ll n;
 cin>>n;
 vector<ll> v(n);
 for(int i=0;i<n;i++)
 {cin>>v[i];}
	for(int i=0;i<n;i++)
	{
		ll a = 1;
		for(int j=0;j<n;j++)
			if(v[j] > v[i]) a++;
		cout << a << " ";
	}
	cout <<endl;
	}
int main()
{ 
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll t = 1;
  // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

		   	  	   	 	   	 	  				   	


Comments

Submit
0 Comments
More Questions

Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons